﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lastfm;
using Lastfm.Services;

namespace Meridian.Helpers
{
    public class LastFmHelper
    {
        const string ApiKey = "a012acc1e5f8a61bc7e58238ce3021d8";
        const string ApiSecret = "86776d4f43a72633fb37fb28713a7798";
        private readonly Session session;

        public LastFmHelper()
        {
            session = new Session(ApiKey, ApiSecret);
        }

        public Track[] SearchForAlbum(string query)
        {
            var search = new AlbumSearch(query, session);
            Album match;
            try
            {
                match = search.GetFirstMatch();
            }
            catch (Exception)
            {
                return null;
            }
            return match == null ? null : match.GetTracks();
        }
    }
}
